#Ввод
s = input("Введите скобочную последовательность: ")

c_1 = 0
c_2 = 0
c_3 = 0
c_4 = 0
#Проверка на ()()()
for j in s:
    if j == "(":
        c_1 += 1
    if c_1 > 0 and j == ")":
        c_1 -= 1
#Проверка на [][][]        
for j in s:
    if j == "[":
        c_2 += 1
    if c_2 > 0 and j == "]":
        c_2 -= 1
#Проверка на <><><>
for j in s:
    if j == "<":
        c_3 += 1
    if c_3 > 0 and j == ">":
        c_3 -= 1
#Проверка на {}{}{}
for j in s:
    if j == "{":
        c_4 += 1
    if c_4 > 0 and j == "}":
        c_4 -= 1


#Вывод
if c_1 == 0 and c_2 == 0 and c_3 == 0 and c_4 == 0:
    print("True")
else:
    print("False")
